package com.joker.demo.core.domain.enums;


/**
 * 任务运行时状态枚举
 *
 * @author : feixiang.li
 * @since : 2025-07-23 21:26
 */
public enum JobRunStatusEnum {

    /**
     * 初始化，运行中，运行完成，运行失败，运行取消
     */
    INIT(0, "初始化"),
    /**
     * 请求发送中
     */
    REQUESTING(1, "请求发送中"),
    RUNNING(2, "运行中"),
    /**
     * 运行结果。错过
     */
    MISSED(3, "错过"),
    TIMEOUT(4, "超时"),
    COMPLETED(5, "运行完成"),
    FAILED(6, "运行失败"),

    /**
     * 取消
     */
    CANCELING(7, "运行取消中"),
    CANCELED(8, "取消成功");
    private final Integer code;
    private final String desc;

    JobRunStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static JobRunStatusEnum getByCode(Integer code) {
        for (JobRunStatusEnum value : JobRunStatusEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }
}
